package com.appcan.sync.common;

import java.io.File;
import java.net.URL;

import javax.servlet.Servlet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * ��ʱ���?���ļ���
 * @author Administrator
 *
 */
public class SyncLicenceJob implements Job {
   
	private static final Log log = LogFactory.getLog(SyncLicenceJob.class);
	
	public void execute(JobExecutionContext arg0) throws JobExecutionException {
		log.debug("���?���ļ��п�ʼ����������");
		String basePath = Servlet.class.getClassLoader().getResource("").toString();
		String filepath2 = "";//MerpConst.XPAD_DownLoad;
		String foldername = basePath+filepath2;
		try {
			File  file = new File(new URL(foldername).toURI());
			this.deleteFile(file);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e);
		}
		log.debug("���?���ļ��н���������");
	}
	 private  boolean deleteFile(File file){   
	        File[] files = file.listFiles();   
	        for(File deleteFile : files){   
	            if(deleteFile.isDirectory()){   
	                if(!deleteFile(deleteFile)){   
	                    continue;  
	                }  
	                if(!deleteFile.delete())continue;
	            } else {   
	                if(!deleteFile.delete()){   
	                   continue;   
	                }   
	            }   
	        }   
	        return true;
	    }  

}
